#include "led.h"

#define CPLD_LED		*((volatile unsigned char *)0x20800000)

int led_init(void)
{
	CPLD_LED = 0x0;
	return 0;
}

int led_on(int num)
{
	CPLD_LED |= 1<<num;
	
	return 0;
}

int led_off(int num)
{
	CPLD_LED &= ~(1<<num);
	
	return 0;
}
static void delay(int time)
{
	int i,j;
	
	for (i = 0; i < time; i++)
		for (j = 0; j < 6000000; j++)
		;
}

int led_on_all(void)
{
	CPLD_LED |= 0xff;
	
	return 0;
}

int led_off_all(void)
{
	CPLD_LED &= 0x0;
	
	return 0;
}

int led_test(int argc, char *argv[])
{
	int i;	
	led_init();
	
	for (i = 0; i < 8; i++){
		led_on(i);
		delay(1);
        }
	
	for (i = 0; i < 2; i++){
	led_off_all();
	delay(1);
	led_on_all();
	delay(1);
	}
	return 0;
}


